#include "Widget.h"

#include <QtGui/QApplication>
#include <QtDeclarative/QDeclarativeView>
#include <QtDeclarative/QDeclarativeEngine>
#include <QtGui/QDesktopWidget>
#include <QtGui/QVBoxLayout>

Widget::Widget(QWidget *parent)
	: QWidget(parent)
{
	setWindowFlags(Qt::FramelessWindowHint);
	setAttribute(Qt::WA_TranslucentBackground);
	setAttribute(Qt::WA_NoSystemBackground);

	view = new QDeclarativeView(this);
	view->engine()->addImportPath("./imports");
	view->setSource(QUrl("qrc:/Boofer-QML/Boofer-QML.qml"));
	view->viewport()->setAutoFillBackground(false);
	view->setResizeMode(QDeclarativeView::SizeViewToRootObject);
	view->setFocusPolicy(Qt::WheelFocus);
	view->setFocus();

	QVBoxLayout * layout = new QVBoxLayout(this);
	layout->addWidget(view);

	setLayout(layout);
}

Widget::~Widget()
{

}

void Widget::showEvent(QShowEvent *)
{
	adjustSize();
	move(QApplication::desktop()->screen()->rect().center() - rect().center());
}
